package com;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.enhydra.xml.xmlc.servlet.XMLCContext;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * 
 * @author Charith
 * @web.servlet
 *   name="Test"
 *   @web.servlet-mapping
 *     url-pattern="/test"
 */
public class Test extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		XMLCContext xmlc = XMLCContext.getContext(this);
		testHTML html = (testHTML)xmlc.getXMLCFactory().create(testHTML.class);
		String selectTest = req.getParameter("selectTest");
		html.setTextSuccessful(selectTest );
		Element element = html.createElement("div");
		Node node = html.createTextNode("dynamic html");
		element.setAttribute("style","display: true; color:blue;position: absolute; top: 10px; left: 10;color: red; background: blue; width: 125px; padding: 5px; margin: 10px; z-index: 100; ");
		element.appendChild(node);
		
		html.getBody().appendChild(element);
		xmlc.writeDOM(req, resp, html);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doGet(req, resp);
	}

}
